(function (vc) {
    vc.extends({
        propTypes: {
            emitchooseCouponPoolSend: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseCouponPoolSendInfo: {
                couponPools: [],
                _currentCouponPoolName: ''
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseCouponPoolSend', 'openchooseCouponPoolSendModel', function (_param) {
                $('#chooseCouponPoolSendModel').modal('show');
                $that._refreshchooseCouponPoolSendInfo();
                $that._loadSendCouponPoolInfo(1, 10, '');
            });
            vc.on('chooseCouponPoolSend','paginationPlus', 'page_event', function (_currentPage) {
                $that._loadSendCouponPoolInfo(_currentPage, 10,'');
            });
        },
        methods: {
            _loadSendCouponPoolInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        shopId: vc.getCurrentCommunity().shopId,
                        name: _name
                    }
                };
                //发送get请求
                vc.http.apiGet('couponShopPool.listCouponShopPool',
                    param,
                    function (json) {
                        var _couponPoolInfo = JSON.parse(json);
                        $that.chooseCouponPoolSendInfo.couponPools = _couponPoolInfo.data;
                        vc.emit('chooseCouponPoolSend','paginationPlus', 'init', {
                            total: _couponPoolInfo.records,
                            currentPage: _page
                        });
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseCouponPoolSend: function (_couponPool) {
                if (_couponPool.hasOwnProperty('name')) {
                    _couponPool.couponPoolName = _couponPool.name;
                }
                _couponPool.data = $that.chooseCouponPoolSendInfo.data;
                vc.emit($props.emitchooseCouponPoolSend, 'chooseCouponPoolSend', _couponPool);
                $('#chooseCouponPoolSendModel').modal('hide');
            },
            queryCouponPools: function () {
                $that._loadSendCouponPoolInfo(1, 10, $that.chooseCouponPoolSendInfo._currentCouponPoolName);
            },
            _refreshchooseCouponPoolSendInfo: function () {
                $that.chooseCouponPoolSendInfo._currentCouponPoolName = "";
            }
        }

    });
})(window.vc);
